import { AxiosPromise } from 'axios'
import request from '../../utils/request'

// 获取分页列表
export function getPageList(APIUrl: string, params: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/page`,
    method: 'get',
    params
  })
}
// 获取列表
export function getList(APIUrl: string, params: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/list`,
    method: 'get',
    params
  })
}
// 新增
export function create(APIUrl: string, data: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/save`,
    method: 'post',
    data
  })
}

// 修改
export function update(APIUrl: string, data: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/update`,
    method: 'post',
    data
  })
}

// 删除
export function remove(APIUrl: string, data: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/remove`,
    method: 'post',
    data
  })
}

// 获取详情
export function read(APIUrl: string, params: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/get`,
    method: 'get',
    params
  })
}

// 上架
export function shelve(APIUrl: string, data: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/shelve`,
    method: 'post',
    data
  })
}

// 下架
export function unshelve(APIUrl: string, data: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/unshelve`,
    method: 'post',
    data
  })
}

// 导出
export function exportList(APIUrl: string, params: any): AxiosPromise<any> {
  return request({
    url: `${APIUrl}/export`,
    method: 'get',
    params
  })
}

// 上传头像获取七牛token
export function getQiniuToken(params: { fullName: string; category: string }): Promise<any> {
  return request({
    url: '/file/qiniu/getAuth',
    method: 'get',
    params
  })
}
